import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import set from '@dfeidao/atom-web/local/set';
import set_node_cls from '@dfeidao/atom-web/ui/set-node-cls';
import show from '@dfeidao/atom-web/ui/show';

export default async function a001(fd: IFeidaoAiBrowserComponent, exam_id: string, candidate_no: string, question_numbers: { d: Array<{}>, d1: Array<{}>, d2: Array<{}> }, paper_number: string, right_answer: Array<{}>, answers: Array<{ valu: string; no: string }>, exam_scores: string, dt: Array<{ topic: string }>, dt1: Array<{ topic: string }>, dt2: Array<{ topic: string }>) {
	// todo
	// 所属试题编号：
	const question_number = question_numbers[0].concat(question_numbers[1].concat(question_numbers[2]));
	const answer = Array();
	const fzno = Array();
	const topic = Array();
	// 题目：
	for (let i = 0; i < dt.length; i++) {
		topic.push(dt[i]);
	}
	for (let i = 0; i < dt1.length; i++) {
		topic.push(dt1[i]);
	}
	for (let i = 0; i < dt2.length; i++) {
		topic.push(dt2[i]);
	}
	// 试卷编号 以及答案
	for (let i = 0; i < answers.length; i++) {
		if (answers[i].no === "") {
			fzno.push(i + 1);
			answer.push("");
		} else {
			fzno.push(answers[i].no);
			answer.push(answers[i].valu);
		}
	}
	const exam_score = Number(exam_scores);
	// 试卷编号：
	set(fd, 'paper_number', paper_number);
	// 所属试题编号：
	set(fd, 'question_number', question_number);
	// 答案
	set(fd, 'answer', answer);
	// 正确答案：
	set(fd, 'right_answer', right_answer);
	// 总分
	set(fd, 'exam_score', exam_score);
	// 顺序号：
	set(fd, 'fzno', fzno);
	// 题目：
	set(fd, 'topic', topic);
	// 考试编号：
	set(fd, 'exam_id', exam_id);
	// 考生编号：
	set(fd, 'candidate_no', candidate_no);
	// 显示组件
	const up = fd.data.node.querySelector<HTMLDivElement>('[data-id="sumit"]');
	set_node_cls(up, 'display-n', false);
	show(fd.data.node);
}
